package cn.tedu.submarine;

import javax.swing.*;

public class BossBomb extends SeaObject {
    public static final int LEFT = 0;
    public static final int MIDDLE = 1;
    public static final int Right = 2;
    private int bossBoMarker = MIDDLE;
    private int fire;

    public BossBomb(int width, int hight, int x, int y, int speed, int bossBoMarker,int fire) {
        super(width, hight, x, y, speed);
        this.bossBoMarker = bossBoMarker;
        this.fire = fire;
    }


    public void move() {
        if (bossBoMarker == LEFT) {
            setX(getX() - getSpeed() / 2);
            setY(getY() - getSpeed());
        } else if (bossBoMarker == Right) {
            setX(getX() + getSpeed() / 2);
            setY(getY() - getSpeed());
        } else if (bossBoMarker == MIDDLE) {
            setY(getY() - getSpeed());
        }
    }

    public boolean isOutBounds(){
        return getY() <= 0 || getX() <= 0-getWidth() ||getX()>= World.WIDTH;
    }

    public int getFire() {
        return fire;
    }

    int index = 0;
    int bossBombIndex=0;
    public ImageIcon getImage() {
        if (fire==1){
            return Images.bossbomb;
        }else {
            bossBombIndex++;
            if (bossBombIndex%5==0) {
                index++;
            }
            if (index % 2 == 0) {
                return Images.bossbombnum[0];
            } else {
                return Images.bossbombnum[1];
            }
        }
    }
}
